﻿//********************************************************************************//
//创建日期：<创建日期，2017-03-28>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：深层承压水取水井 编辑/详细信息
//********************************************************************************//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;
using BLL.Access;
using System.Data;
using Platform.Http;
using Web.Class;
using Platform.Common;

namespace Web.Pages.QuShui.ShuiLiPC
{
    public partial class QuShuiJXX : BasePage
    {
        /// <summary>
        /// id
        /// </summary>
        private int id;

        /// <summary>
        /// 操作类型
        /// </summary>
        private int cz;

        /// <summary>
        /// 从井信息传过来的井名称
        /// </summary>
        private string jmc;

        #region 变量
        /// <summary>
        /// 水利普查
        /// </summary>
        QS_SLPCSJ1 SLPC = new QS_SLPCSJ1();

        /// <summary>
        /// 水利普查
        /// </summary>
        QS_SLPCSJ1BLL SLPCBLL = new QS_SLPCSJ1BLL();

        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();

        /// <summary>
        /// 操作日志BLL
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();


        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.id = Convert.ToInt32(Request.QueryString["bh"]);
            this.cz = Convert.ToInt32(Request.QueryString["cz"]);
            if (cz == 3)
            {
                this.jmc = Request.QueryString["jmc"].ToString();
                if (this.jmc != "")
                {
                    LoadID(this.jmc);
                }
            }
            // string a = UrlDecode(jmc);
            //第一次页面加载
            if (!IsPostBack)
            {
                if (cz == 1)
                {
                    setVisable(true);
                }
                else
                {
                    setVisable(false);
                }

                if (this.id != 0)
                {
                    LoadData();
                }

            }

        }


        /// <summary>
        /// 保存到数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            OperateState operateState;
            //修改操作
            operateState = OperateState.Modify;

            //记录ID 只是用于记录修改日志
            SLPC = this.SLPCBLL.SelectQS_SLPCSJ1(id);
            SLPC.ID = id;
            SLPC.S_MINGCHENG = txtMC.Text != "" ? txtMC.Text : null;
            SLPC.S_BIANHAO = txtBianMa.Text != "" ? txtBianMa.Text : null;
            SLPC.S_SHENG = txtSheng.Text != "" ? txtSheng.Text : null;
            SLPC.S_XIAN = txtXian.Text != "" ? txtXian.Text : null;
            SLPC.S_ZHEN = txtXiang.Text != "" ? txtXiang.Text : null;
            SLPC.S_JIE = txtJie.Text != "" ? txtJie.Text : null;
            SLPC.S_JUTIWZ = txtJTWZ.Text != "" ? txtJTWZ.Text : null;
            SLPC.S_DJ1 = txtDJ1.Text != "" ? txtDJ1.Text : null;
            SLPC.S_DJ2 = txtDJ2.Text != "" ? txtDJ2.Text : null;
            SLPC.S_DJ3 = txtDJ3.Text != "" ? txtDJ3.Text : null;
            SLPC.S_BW1 = txtBW1.Text != "" ? txtBW1.Text : null;
            SLPC.S_BW2 = txtBW2.Text != "" ? txtBW2.Text : null;
            SLPC.S_BW3 = txtBW3.Text != "" ? txtBW3.Text : null;
            SLPC.S_ZUOBIAO_X = txtZB_X.Text != "" ? txtZB_X.Text : null;
            SLPC.S_ZUOBIAO_Y = txtZB_Y.Text != "" ? txtZB_Y.Text : null;
            int? cjsj = txtCJSJ.Text != "" ? (int?)(Convert.ToDecimal(txtCJSJ.Text)) : null;
            SLPC.I_CHENGJSJ = cjsj;
            SLPC.I_JINGSHEN = txtJS.Text != "" ? (int?)(Convert.ToDecimal(txtJS.Text)) : null;
            SLPC.I_DIXIAMS = txtDXMS.Text != "" ? (int?)(Convert.ToDecimal(txtDXMS.Text)) : null;//txtDXMS.Text =;
            SLPC.S_SFWDWZBJ = txtSFWDWZBJ.Text != "" ? txtSFWDWZBJ.Text : null;
            SLPC.I_JINGNJ = txtJNJ.Text != "" ? (int?)(Convert.ToDecimal(txtJNJ.Text)) : null;// txtJNJ.Text;
            SLPC.S_JINGBICL = txtJBCL.Text != "" ? txtJBCL.Text : null;
            SLPC.S_YINGYONGZK = txtYYZT.Text != "" ? txtYYZT.Text : null;
            SLPC.S_SFYPDJDSB = txtSFYPDJDSB.Text != "" ? txtSFYPDJDSB.Text : null;
            SLPC.S_SHUIBENGXH = txtSBXH.Text != "" ? txtSBXH.Text : null;
            SLPC.I_YANGCHENG = txtSBEDYC.Text != "" ? (int?)(Convert.ToDecimal(txtSBEDYC.Text)) : null;//txtSBEDYC.Text
            SLPC.I_LIULIANG = txtSBEDLL.Text != "" ? (int?)(Convert.ToDecimal(txtSBEDLL.Text)) : null;//txtSBEDLL.Text
            SLPC.I_GONGLV = txtSPEDGL.Text != "" ? (int?)(Convert.ToDecimal(txtSPEDGL.Text)) : null;//txtSPEDGL.Text
            SLPC.S_SFYAZSLJLSS = txtSFYAZSLJLSS.Text != "" ? txtSFYAZSLJLSS.Text : null;
            SLPC.S_JILIANGSSLX = txtSLJLSSLX.Text != "" ? txtSLJLSSLX.Text : null;
            SLPC.S_SFWGMJDJ = txtSFWGMJDJ.Text != "" ? txtSFWGMJDJ.Text : null;
            SLPC.S_SHUIYUANDMC = txtSZSYDMC.Text != "" ? txtSZSYDMC.Text : null;
            SLPC.S_SHUIYUANDBM = txtSZSYDBM.Text != "" ? txtSZSYDBM.Text : null;
            SLPC.S_DIMAOLX = txtSZDMLXQ.Text != "" ? txtSZDMLXQ.Text : null;
            SLPC.S_DIXIASLX = txtSQYDXSLX.Text != "" ? txtSQYDXSLX.Text : null;
            SLPC.S_SIJIQMC = txtSZYSJQMC.Text != "" ? txtSZYSJQMC.Text : null;
            SLPC.S_SIJIQBM = txtSZYSJQBM.Text != "" ? txtSZYSJQBM.Text : null;
            SLPC.S_SHUIYUANLX = txtSYLX.Text != "" ? txtSYLX.Text : null;
            SLPC.S_QUSHUIYTXY = txtZYYTJXY.Text != "" ? txtZYYTJXY.Text : null;
            SLPC.I_GONGSHUIRK = txtXCSJGSRK.Text != "" ? (int?)(Convert.ToDecimal(txtXCSJGSRK.Text)) : null;//txtXCSJGSRK.Text =
            SLPC.S_GUANQULX = txtGQLX.Text != "" ? txtGQLX.Text : null;
            SLPC.N_GUANGAIMJ = txtKZGGMJ.Text != "" ? (double?)(Convert.ToDecimal(txtKZGGMJ.Text)) : null;//txtKZGGMJ.Text =
            SLPC.N_SHIJIGGMJ = txtSJGGMJ.Text != "" ? (double?)(Convert.ToDecimal(txtSJGGMJ.Text)) : null;//txtSJGGMJ.Text = 
            SLPC.S_QUSHUIYT = txtQSYT.Text != "" ? txtQSYT.Text : null;
            SLPC.S_SHUIWEN = txtSW.Text != "" ? txtSW.Text : null;
            SLPC.S_QSLQDFF = txtQSLQDFF.Text != "" ? txtQSLQDFF.Text : null;
            SLPC.S_QNHDL = txtQNHDL.Text != "" ? txtQNHDL.Text : null;
            SLPC.S_QNHYL = txtQNHYL.Text != "" ? txtQNHYL.Text : null;
            SLPC.S_QNKBSS = txtQNKBSS.Text != "" ? txtQNKBSS.Text : null;
            SLPC.S_DWHDLDQSL = txtDWHDLQSL.Text != "" ? txtDWHDLQSL.Text : null;
            SLPC.S_DWHYLDQSL = txtDWHYLQSL.Text != "" ? txtDWHYLQSL.Text : null;
            SLPC.S_SBDWSJCSL = txtSBDWSJCSL.Text != "" ? txtSBDWSJCSL.Text : null;
            SLPC.S_SJFQSL = txtSCFQSL.Text != "" ? txtSCFQSL.Text : null;
            SLPC.S_HDLFQSL = txtHDLFQSL.Text != "" ? txtHDLFQSL.Text : null;
            SLPC.S_HYLFQSL = txtHYLFQSL.Text != "" ? txtHYLFQSL.Text : null;
            SLPC.S_CSLFQSL = txtCSLFQSL.Text != "" ? txtCSLFQSL.Text : null;
            SLPC.S_SFYBLQSXKZ = txtSFYBLQSXKZ.Text != "" ? txtSFYBLQSXKZ.Text : null;
            SLPC.S_QSXKZBH = txtQSXKZBH.Text != "" ? txtQSXKZBH.Text : null;
            SLPC.S_NXKQSL = txtNXKQSL.Text != "" ? txtNXKQSL.Text : null;
            SLPC.S_SFYBLCKXKZ = txtSFYBLCKXKZ.Text != "" ? txtSFYBLCKXKZ.Text : null;
            SLPC.S_CKXKZZH = txtCKXKZZH.Text != "" ? txtCKXKZZH.Text : null;
            SLPC.N_KUANGQUMJ = txtKQMJ.Text != "" ? (double?)(Convert.ToDecimal(txtKQMJ.Text)) : null;//txtKQMJ.Text
            SLPC.S_SHENGCHANGM = txtSCGM.Text != "" ? txtSCGM.Text : null;
            SLPC.S_GUANLIDWMC = txtGLDWMC.Text != "" ? txtGLDWMC.Text : null;
            SLPC.S_GLDWLSGX = txtGLDWLSGX.Text != "" ? txtGLDWLSGX.Text : null;
            SLPC.S_TIANBIAOR = txtTBR.Text != "" ? txtTBR.Text : null;
            SLPC.S_DIANHUA1 = txtLXDH1.Text != "" ? txtLXDH1.Text : null;//a.Text != "" ? (int?)(Convert.ToDecimal(a.Text)) : null
            SLPC.I_Y1 = txtY1.Text != "" ? (int?)(Convert.ToDecimal(txtY1.Text)) : null;
            SLPC.I_M1 = txtM1.Text != "" ? (int?)(Convert.ToDecimal(txtM1.Text)) : null;
            SLPC.I_D1 = txtD1.Text != "" ? (int?)(Convert.ToDecimal(txtD1.Text)) : null;
            SLPC.S_FUHER = txtFHR.Text != "" ? txtFHR.Text : null;
            SLPC.I_Y2 = txtY2.Text != "" ? (int?)(Convert.ToDecimal(txtY2.Text)) : null;
            SLPC.I_M2 = txtM2.Text != "" ? (int?)(Convert.ToDecimal(txtM2.Text)) : null;
            SLPC.I_D2 = txtD2.Text != "" ? (int?)(Convert.ToDecimal(txtD2.Text)) : null;
            SLPC.S_SHENCHAR = txtSHR.Text != "" ? txtSHR.Text : null;
            SLPC.I_Y3 = txtY3.Text != "" ? (int?)(Convert.ToDecimal(txtY3.Text)) : null;
            SLPC.I_M3 = txtM3.Text != "" ? (int?)(Convert.ToDecimal(txtM3.Text)) : null;
            SLPC.I_D3 = txtD3.Text != "" ? (int?)(Convert.ToDecimal(txtD3.Text)) : null;
            SLPC.S_SHANGBAODW = txtSBDW.Text != "" ? txtSBDW.Text : null;
            bool result = SLPCBLL.InsertOrUpdate(SLPC);
            if (result)
            {
                _SYS_LOGBLL.Log<QS_SLPCSJ1>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "深层承压水取水井", operateState, SLPC, null);
                PageTools.AlertMsg(this, "保存成功！");
                LoadData();
                // this.Status = GridViewStatus.Search;

            }
            else
            {
                PageTools.AlertMsg(this, "保存失败！");
            }
        }
        #endregion

        #region 方法

        private void LoadID(string mc)
        {
            //select * from qs_yh_shenjingxxb a  inner join QS_SLPCSJ1 b on  a.S_LAOBIANH||'号井'=b.s_mingcheng where a.i_jlzt=0
            DataTable dt = SLPCBLL.SelectQS_SLPCSJ1sDynamic(string.Format("S_MINGCHENG='{0}'", mc + "号井"), null);
            if (dt.Rows.Count > 0)
            {
                this.id = Convert.ToInt32(dt.Rows[0]["ID"]);
            }
            else
            {
                PageTools.AlertMsg(this, "没有匹配到相关水利普查数据！");
                return;
            }
        }

        private void setVisable(bool b)
        {
            txtMC.ClientEnabled = b;
            txtBianMa.ClientEnabled = b;
            txtSheng.ClientEnabled = b;
            txtXian.ClientEnabled = b;
            txtXiang.ClientEnabled = b;
            txtJie.ClientEnabled = b;
            txtJTWZ.ClientEnabled = b;
            txtDJ1.ClientEnabled = b;
            txtDJ2.ClientEnabled = b;
            txtDJ3.ClientEnabled = b;
            txtBW1.ClientEnabled = b;
            txtBW2.ClientEnabled = b;
            txtBW3.ClientEnabled = b;
            txtZB_X.ClientEnabled = b;
            txtZB_Y.ClientEnabled = b;
            txtCJSJ.ClientEnabled = b;
            txtJS.ClientEnabled = b;
            txtDXMS.ClientEnabled = b;
            txtSFWDWZBJ.ClientEnabled = b;
            txtJNJ.ClientEnabled = b;
            txtJBCL.ClientEnabled = b;
            txtYYZT.ClientEnabled = b;
            txtSFYPDJDSB.ClientEnabled = b;
            txtSBXH.ClientEnabled = b;
            txtSBEDYC.ClientEnabled = b;
            txtSBEDLL.ClientEnabled = b;
            txtSPEDGL.ClientEnabled = b;
            txtSFYAZSLJLSS.ClientEnabled = b;
            txtSLJLSSLX.ClientEnabled = b;
            txtSFWGMJDJ.ClientEnabled = b;
            txtSZSYDMC.ClientEnabled = b;
            txtSZSYDBM.ClientEnabled = b;
            txtSZDMLXQ.ClientEnabled = b;
            txtSQYDXSLX.ClientEnabled = b;
            txtSZYSJQMC.ClientEnabled = b;
            txtSZYSJQBM.ClientEnabled = b;
            txtSYLX.ClientEnabled = b;
            txtZYYTJXY.ClientEnabled = b;
            txtXCSJGSRK.ClientEnabled = b;
            txtGQLX.ClientEnabled = b;
            txtKZGGMJ.ClientEnabled = b;
            txtSJGGMJ.ClientEnabled = b;
            txtQSYT.ClientEnabled = b;
            txtSW.ClientEnabled = b;
            txtQSLQDFF.ClientEnabled = b;
            txtQNHDL.ClientEnabled = b;
            txtQNHYL.ClientEnabled = b;
            txtQNKBSS.ClientEnabled = b;
            txtDWHDLQSL.ClientEnabled = b;
            txtDWHYLQSL.ClientEnabled = b;
            txtSBDWSJCSL.ClientEnabled = b;
            txtSCFQSL.ClientEnabled = b;
            txtHDLFQSL.ClientEnabled = b;
            txtHYLFQSL.ClientEnabled = b;
            txtCSLFQSL.ClientEnabled = b;
            txtSFYBLQSXKZ.ClientEnabled = b;
            txtQSXKZBH.ClientEnabled = b;
            txtNXKQSL.ClientEnabled = b;
            txtSFYBLCKXKZ.ClientEnabled = b;
            txtCKXKZZH.ClientEnabled = b;
            txtKQMJ.ClientEnabled = b;
            txtSCGM.ClientEnabled = b;
            txtGLDWMC.ClientEnabled = b;
            txtGLDWLSGX.ClientEnabled = b;
            txtTBR.ClientEnabled = b;
            txtLXDH1.ClientEnabled = b;
            txtY1.ClientEnabled = b;
            txtM1.ClientEnabled = b;
            txtD1.ClientEnabled = b;
            txtFHR.ClientEnabled = b;
            txtY2.ClientEnabled = b;
            txtM2.ClientEnabled = b;
            txtD2.ClientEnabled = b;
            txtSHR.ClientEnabled = b;
            txtY3.ClientEnabled = b;
            txtM3.ClientEnabled = b;
            txtD3.ClientEnabled = b;
            txtSBDW.ClientEnabled = b;
            btnSave.Visible = b;
        }

        

        /// <summary>
        /// 数据加载
        /// </summary>
        private void LoadData()
        {
            SLPC = SLPCBLL.SelectQS_SLPCSJ1(id);
            txtMC.Text=SLPC.S_MINGCHENG;
            txtBianMa.Text = SLPC.S_BIANHAO;
            txtSheng.Text = SLPC.S_SHENG;
            txtXian.Text = SLPC.S_XIAN;
            txtXiang.Text = SLPC.S_ZHEN;
            txtJie.Text = SLPC.S_JIE;
            txtJTWZ.Text = SLPC.S_JUTIWZ;
            txtDJ1.Text = SLPC.S_DJ1;
            txtDJ2.Text = SLPC.S_DJ2;
            txtDJ3.Text = SLPC.S_DJ3;
            txtBW1.Text = SLPC.S_BW1;
            txtBW2.Text = SLPC.S_BW2;
            txtBW3.Text = SLPC.S_BW3;
            txtZB_X.Text = SLPC.S_ZUOBIAO_X;
            txtZB_Y.Text = SLPC.S_ZUOBIAO_Y;
            txtCJSJ.Text = SLPC.I_CHENGJSJ.ToString();
            txtJS.Text = SLPC.I_JINGSHEN.ToString();
            txtDXMS.Text = SLPC.I_DIXIAMS.ToString();
            txtSFWDWZBJ.Text = SLPC.S_SFWDWZBJ;
            txtJNJ.Text = SLPC.I_JINGNJ.ToString();
            txtJBCL.Text = SLPC.S_JINGBICL;
            txtYYZT.Text = SLPC.S_YINGYONGZK;
            txtSFYPDJDSB.Text = SLPC.S_SFYPDJDSB;
            txtSBXH.Text = SLPC.S_SHUIBENGXH;
            txtSBEDYC.Text = SLPC.I_YANGCHENG.ToString();
            txtSBEDLL.Text = SLPC.I_LIULIANG.ToString();
            txtSPEDGL.Text = SLPC.I_GONGLV.ToString();
            txtSFYAZSLJLSS.Text = SLPC.S_SFYAZSLJLSS;
            txtSLJLSSLX.Text = SLPC.S_JILIANGSSLX;
            txtSFWGMJDJ.Text = SLPC.S_SFWGMJDJ;
            txtSZSYDMC.Text = SLPC.S_SHUIYUANDMC;
            txtSZSYDBM.Text = SLPC.S_SHUIYUANDBM;
            txtSZDMLXQ.Text = SLPC.S_DIMAOLX;
            txtSQYDXSLX.Text = SLPC.S_DIXIASLX;
            txtSZYSJQMC.Text = SLPC.S_SIJIQMC;
            txtSZYSJQBM.Text = SLPC.S_SIJIQBM;
            txtSYLX.Text = SLPC.S_SHUIYUANLX;
            txtZYYTJXY.Text = SLPC.S_QUSHUIYTXY;
            txtXCSJGSRK.Text = SLPC.I_GONGSHUIRK.ToString();
            txtGQLX.Text = SLPC.S_GUANQULX;
            txtKZGGMJ.Text = SLPC.N_GUANGAIMJ.ToString();
            txtSJGGMJ.Text = SLPC.N_SHIJIGGMJ.ToString();
            txtQSYT.Text = SLPC.S_QUSHUIYT;
            txtSW.Text = SLPC.S_SHUIWEN;
            txtQSLQDFF.Text = SLPC.S_QSLQDFF;
            txtQNHDL.Text = SLPC.S_QNHDL;
            txtQNHYL.Text = SLPC.S_QNHYL;
            txtQNKBSS.Text = SLPC.S_QNKBSS;
            txtDWHDLQSL.Text = SLPC.S_DWHDLDQSL;
            txtDWHYLQSL.Text = SLPC.S_DWHYLDQSL;
            txtSBDWSJCSL.Text = SLPC.S_SBDWSJCSL;
            txtSCFQSL.Text = SLPC.S_SJFQSL;
            txtHDLFQSL.Text = SLPC.S_HDLFQSL;
            txtHYLFQSL.Text = SLPC.S_HYLFQSL;
            txtCSLFQSL.Text = SLPC.S_CSLFQSL;
            txtSFYBLQSXKZ.Text = SLPC.S_SFYBLQSXKZ;
            txtQSXKZBH.Text = SLPC.S_QSXKZBH;
            txtNXKQSL.Text = SLPC.S_NXKQSL;
            txtSFYBLCKXKZ.Text = SLPC.S_SFYBLCKXKZ;
            txtCKXKZZH.Text = SLPC.S_CKXKZZH;
            txtKQMJ.Text = SLPC.N_KUANGQUMJ.ToString();
            txtSCGM.Text = SLPC.S_SHENGCHANGM;
            txtGLDWMC.Text = SLPC.S_GUANLIDWMC;
            txtGLDWLSGX.Text = SLPC.S_GLDWLSGX;
            txtTBR.Text = SLPC.S_TIANBIAOR;
            txtLXDH1.Text = SLPC.S_DIANHUA1;
            txtY1.Text = SLPC.I_Y1.ToString();
            txtM1.Text = SLPC.I_M1.ToString();
            txtD1.Text = SLPC.I_D1.ToString();
            txtFHR.Text = SLPC.S_FUHER;
            txtY2.Text = SLPC.I_Y2.ToString();
            txtM2.Text = SLPC.I_M2.ToString();
            txtD2.Text = SLPC.I_D2.ToString();
            txtSHR.Text = SLPC.S_SHENCHAR;
            txtY3.Text = SLPC.I_Y3.ToString();
            txtM3.Text = SLPC.I_M3.ToString();
            txtD3.Text = SLPC.I_D3.ToString();
            txtSBDW.Text = SLPC.S_SHANGBAODW;
           
        }

        #endregion        

       
      
        
    }
}